package com.loongtech.bi.action.report;

import com.loongtech.bi.entity.system.EntityBiServer;
import com.loongtech.bi.manager.report.CountryServerReportManager;
import com.loongtech.bi.manager.report.CountryServerReportManager.GameReportData;
import com.loongtech.bi.manager.system.BiPlatformManager;
import com.loongtech.bi.manager.system.SysLogManager;
import com.loongtech.bi.support.Session;
import com.loongtech.core.util.Time;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.*;

/**
 * Author: yuri
 * Description: 运营报表-国家区服
 * Date: 11:52 2017/6/26
 */
@Controller("countryServerReportActionOld")
@Scope("view")
public class CountryServerReportActionOld {
    private Date dateStart = new Date(Time.getBeginningOfDay(Time.currentTime() - 7 * Time.DAY));  // 自选时间：开始时间
    private Date dateEnd = new Date(Time.getBeginningOfDay(Time.currentTime() - Time.DAY));  // 自选时间：结束时间

    private String queryServer = "0";  // 前端传过来的查询条件：区服
    private Map<String, String> serverItmes;  // 区服下拉列表

    private List<GameReportData> countryDataList;  // 后台返回国家数据

    @Resource
    private CountryServerReportManager countryServerReportManager;
    @Resource
    private SysLogManager sysLogManager;
    @Resource
    private Session session;

    @PostConstruct
    public void init() {
        search();
    }

    public void search() {
        sysLogManager.addLog(session.getUserName(), "查询运营报表-区服国家");
        serverItmes = new LinkedHashMap<>();
        serverItmes.put("全区服", "0");
        for (EntityBiServer p : BiPlatformManager.SERVER_LIST) {
            serverItmes.put(p.getName(), p.getId());
        }
        countryDataList = new ArrayList<>();
        List<GameReportData> allData = countryServerReportManager.getCountryServerReportData(queryServer, dateStart, dateEnd);
        if (allData != null && allData.size() > 0) {
            countryDataList = countryServerReportManager.updateData(allData);
        }
    }

    public Date getDateStart() {
        return dateStart;
    }

    public void setDateStart(Date dateStart) {
        this.dateStart = dateStart;
    }

    public Date getDateEnd() {
        return dateEnd;
    }

    public void setDateEnd(Date dateEnd) {
        this.dateEnd = dateEnd;
    }


    public String getQueryServer() {
        return queryServer;
    }

    public void setQueryServer(String queryServer) {
        this.queryServer = queryServer;
    }

    public Map<String, String> getServerItmes() {
        return serverItmes;
    }

    public void setServerItmes(Map<String, String> serverItmes) {
        this.serverItmes = serverItmes;
    }

    public List<GameReportData> getCountryDataList() {
        return countryDataList;
    }

    public void setCountryDataList(List<GameReportData> countryDataList) {
        this.countryDataList = countryDataList;
    }
}
